package com.fengzai.queue;

import com.fengzai.utils.ZkUtil;
import org.apache.curator.framework.CuratorFramework;
import org.apache.zookeeper.CreateMode;

/**
 * Created by  峰仔  on 2017-08-10
 * 分布式队列  入队
 */
public class Enqueue {
    public static void main(String[] args) throws Exception {
        CuratorFramework curatorFramework = ZkUtil.getInstace("queue");
        //生成10个任务的队列
        for (int i = 0; i < 10; i++) {
            String s = curatorFramework.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath("/task", ("task" + i).getBytes());
            System.out.println("任务名称：task" + i + "     ----->    " + "所在的节点:" + s);
        }

    }
}
